package com.smartgame.objects;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;

public class Spiders extends AnimatedObject {

	public Spiders(Texture animatedTexture) {
		super(animatedTexture);
		initObject();
	}

	public void initObject() {
		dimension.set(0.5f, 0.5f);

		// Center image on game object
		position.set(-dimension.x / 2, -dimension.y / 2);
		origin.set(dimension.x / 2, dimension.y / 2);

		// Set physics values
		terminalVelocity.set(3.0f, 0.0f);
	};

	@Override
	public void update(float deltaTime) {
		super.update(deltaTime);
		
		// my own update goes here!
		this.velocity = new Vector2(1f, 0f);
		
	}

	@Override
	public void render(SpriteBatch batch) {
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
        stateTime += Gdx.graphics.getDeltaTime();
        currentFrame = animation.getKeyFrame(stateTime, true);
		
		// Draw image
		batch.draw(currentFrame.getTexture(),
				position.x, position.y,
				origin.x, origin.y,
				dimension.x, dimension.y,
				scale.x, scale.y,
				rotation,
				currentFrame.getRegionX(), currentFrame.getRegionY(),
				currentFrame.getRegionWidth(), currentFrame.getRegionHeight(),
				false, false);
	}
	
	@Override
	public void reset() {
		
	}

	@Override
	protected void initCoefficient() {
		frameDuration = 0.025f;
		frameCols = 6;
		frameRows = 5;
	}

}
